﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SalesInvoice.aspx.cs" Inherits="Main_ServiceInvoice_SalesInvoice"
    Culture="en-GB" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sale Invoice</title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                return false;

            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
        function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }
        function GetLastNumber(str) {
            for (var i = 0; i < str.length; i++) {
                if (!isNaN(str.charAt(i))) {
                    str = str.substring(str.indexOf(str.charAt(i)));
                    break;
                }
            }
            var rgx = new RegExp("[a-zA-Z]");
            if (rgx.test(str)) {
                str = str.substring(1);
                return (GetLastNumber(str));
            }
            else {
                return str;
            }
        }

        function ValidateRequired(id) {
            var lastno = GetLastNumber(id);
            var ddl = document.getElementById(id);
            var flag = true;
            if (document.getElementById("ddlFormat").value == "0") {
                alert('Select Format !');
                document.getElementById("ddlFormat").focus();
                flag = false;
                ddl.value = '0';
            }
            else if (document.getElementById("ddlCustomer").value == "0") {
                alert('Select Customer First!');
                document.getElementById("ddlCustomer").focus();
                flag = false;
                ddl.value = '0';
            }
            else if (document.getElementById("txtRefNo").value == '') {
                alert('Enter Ref No.');
                document.getElementById("txtRefNo").focus();
                flag = false;
                ddl.value = '0';
            }
            else if (document.getElementById("txtDate").value == '') {
                alert('Enter Date');
                document.getElementById("txtDate").focus();
                flag = false;
                ddl.value = '0';
            }
            if (flag == true) {
                if (document.getElementById("txtGrossAmtCtrl" + lastno) != null) {
                    document.getElementById("txtGrossAmtCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtDiscountRateCtrl" + lastno) != null) {
                    document.getElementById("txtDiscountRateCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtDiscountAmtCtrl" + lastno) != null) {
                    document.getElementById("txtDiscountAmtCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtServiceChargeCtrl" + lastno) != null) {
                    document.getElementById("txtServiceChargeCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtServiceChargeAmtCtrl" + lastno) != null) {
                    document.getElementById("txtServiceChargeAmtCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtServiceChargeTotalCtrl" + lastno) != null) {
                    document.getElementById("txtServiceChargeTotalCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtServiceTaxCtrl" + lastno) != null) {
                    document.getElementById("txtServiceTaxCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtPECessCtrl" + lastno) != null) {
                    document.getElementById("txtPECessCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtHECessCtrl" + lastno) != null) {
                    document.getElementById("txtHECessCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtLuxuryCtrl" + lastno) != null) {
                    document.getElementById("txtLuxuryCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtVATCtrl" + lastno) != null) {
                    document.getElementById("txtVATCtrl" + lastno).value = '0';
                }
                if (document.getElementById("txtTaxIncGrandTotalCtrl" + lastno) != null) {
                    document.getElementById("txtTaxIncGrandTotalCtrl" + lastno).value = '0';
                }
                setTimeout('__doPostBack(\'' + id + '\',\'\')', 0);
            }
            return flag;
        }
        function CalculateGrandTotal(id) {
            var lastno = GetLastNumber(id);
            var ServiceTaxRate = parseFloat(document.getElementById("txtServiceTaxRateMain").value).toFixed(2);
            if (ServiceTaxRate == '') {
                ServiceTaxRate = 0;
            }
            var PECessRate = parseFloat(document.getElementById("txtPECessRateMain").value).toFixed(2);
            if (PECessRate == '') {
                PECessRate = 0;
            }
            var HECessRate = parseFloat(document.getElementById("txtHECessRateMain").value).toFixed(2);
            if (HECessRate == '') {
                HECessRate = 0;
            }
            var LuxuaryTaxRate = parseFloat(document.getElementById("txtLuxuaryTaxRateMain").value).toFixed(2);
            if (LuxuaryTaxRate == '') {
                LuxuaryTaxRate = 0;
            }
            document.getElementById("txtServiceTaxCtrl" + lastno).value = '0';
            document.getElementById("txtPECessCtrl" + lastno).value = '0';
            document.getElementById("txtHECessCtrl" + lastno).value = '0';

            var rate = document.getElementById("txtRateCtrl" + lastno).value;
            if (rate == '') {
                rate = 0;
                document.getElementById("txtRateCtrl" + lastno).value = 0;
            }
            var unit2 = 1;
            var unit3 = 1;
            var unit4 = 1;
            var unitMain = 1;
            var TotalUnit = 1;

            if (document.getElementById("hidUnit").value.search('u2') >= 0) {
                unit2 = document.getElementById("txtUnit2Ctrl" + lastno).value;
                if (unit2 == '' && unit2 == 0) {
                    unit2 = 1;
                }
            }
            if (document.getElementById("hidUnit").value.search('u3') >= 0) {
                unit3 = document.getElementById("txtUnit3Ctrl" + lastno).value;
                if (unit3 == '' && unit3 == 0) {
                    unit3 = 1;
                }
            }
            if (document.getElementById("hidUnit").value.search('u4') >= 0) {
                unit4 = document.getElementById("txtUnit4Ctrl" + lastno).value;
                if (unit4 == '' && unit4 == 0) {
                    unit4 = 1;
                }
            }
            unitMain = document.getElementById("txtUnitRateCtrl" + lastno).value;
            if (unitMain == '' && unitMain == 0) {
                unitMain = 1;
            }
            TotalUnit = unit2 * unit3 * unit4 * unitMain;
            if (document.getElementById("ddlService" + lastno).value != "0") {
                var ServiceChargeper = document.getElementById("txtServiceChargeCtrl" + lastno).value;
                if (ServiceChargeper == '') {
                    ServiceChargeper = 0;
                }
                var servicechargeRate = parseFloat((parseFloat(parseFloat(ServiceChargeper) * 100) / 1000 / 10) + 1).toFixed(2);
                var ServiceTaxRate = (parseFloat(parseFloat(ServiceTaxRate) + (parseFloat(PECessRate) / 10) + (parseFloat(HECessRate) / 10)) * 100 / 1000 / 10) + 1;

                if (document.getElementById("hidUnitRate").value == 'yes') {
                    GrossAmt = parseFloat(TotalUnit) * parseFloat(rate);
                    document.getElementById("txtGrossAmtCtrl" + lastno).value = parseFloat(GrossAmt);
                }
                else {
                    GrossAmt = document.getElementById("txtGrossAmtCtrl" + lastno).value;
                }
                if (GrossAmt != null) {
                    var GrossAmount = 0;
                    var serviceChargeAmt = 0;
                    var TotalTaxableAmt = 0;
                    var TotalNonTaxableAmt = 0;
                    var TotalServiceChargeAmt = 0;
                    var TotalServiceTaxAmt = 0;
                    var TotalPECessAmt = 0;
                    var TotalHECessAmt = 0;
                    var TotalLuxuaryTaxAmt = 0;
                    var TotalVatAmt = 0;
                    var TotalAmount = 0;
                    var TotalGrand = 0;
                    var TempTotalAmt = 0;
                    if (document.getElementById("hidTaxableNonTaxable" + lastno).value == 'Taxable') {
                        serviceChargeAmt = (parseFloat(GrossAmt) * parseFloat(ServiceChargeper) / 100).toFixed(2);
                        TempTotalAmt = (parseFloat(GrossAmt) + parseFloat(serviceChargeAmt));
                    }
                    else {
                        serviceChargeAmt = (parseFloat(GrossAmt) * parseFloat(ServiceChargeper) / 100).toFixed(2);
                        TempTotalAmt = (parseFloat(GrossAmt) + parseFloat(serviceChargeAmt));
                    }
                    document.getElementById("txtServiceChargeAmtCtrl" + lastno).value = parseFloat(serviceChargeAmt).toFixed(2);      // Service Charge Amount
                    document.getElementById("txtServiceChargeTotalCtrl" + lastno).value = parseFloat(TempTotalAmt).toFixed(2);   // Total Amount Header
                    // Discount 
                    if (document.getElementById("txtDiscountRateCtrl" + lastno).value == '') {
                        document.getElementById("txtDiscountRateCtrl" + lastno).value = 0;
                    }
                    document.getElementById("txtDiscountAmtCtrl" + lastno).value = (parseFloat(document.getElementById("txtGrossAmtCtrl" + lastno).value) * (parseFloat(document.getElementById("txtDiscountRateCtrl" + lastno).value)) / 100).toFixed(2);

                    var disserper = ((parseFloat(serviceChargeAmt)) * (parseFloat(document.getElementById("txtDiscountAmtCtrl" + lastno).value)) / 100).toFixed(2);      // Service Charge Amount
                    document.getElementById("txtServiceChargeAmtCtrl" + lastno).value = (parseFloat(serviceChargeAmt) - parseFloat(disserper));
                    var distotper = ((parseFloat(TempTotalAmt)) * (parseFloat(document.getElementById("txtDiscountAmtCtrl" + lastno).value)) / 100);
                    document.getElementById("txtServiceChargeTotalCtrl" + lastno).value = ((parseFloat(TempTotalAmt)) - (parseFloat(distotper))).toFixed(2);   // Total Amount Header
                    // Discount End
                    // Service Tax
                    var totalamounthead = parseFloat(document.getElementById("txtServiceChargeTotalCtrl" + lastno).value);
                    if (totalamounthead == '') {
                        totalamounthead = 0;
                    }
                    if (document.getElementById("hidTaxableNonTaxable" + lastno).value == 'Taxable') {
                        document.getElementById("txtServiceTaxCtrl" + lastno).value = parseFloat(parseFloat(totalamounthead) * parseFloat(ServiceTaxRate) / 100).toFixed(2);    // Service Tax
                        document.getElementById("txtPECessCtrl" + lastno).value = (parseFloat(parseFloat(totalamounthead)) * parseFloat(PECessRate / 10) / 100).toFixed(2);   // P.E Cess
                        document.getElementById("txtHECessCtrl" + lastno).value = (parseFloat(parseFloat(totalamounthead)) * parseFloat(HECessRate / 10) / 100).toFixed(2);  // H.E Cess
                        document.getElementById("txtLuxuryCtrl" + lastno).value = '0'; // Luxuary Tax
                        document.getElementById("txtVATCtrl" + lastno).value = '0'; // VAT Tax

                        if (document.getElementById("hidSaleLevel").value == 'ItemLevel') {
                            document.getElementById("txtTaxIncGrandTotalCtrl" + lastno).value = parseFloat(parseFloat(totalamounthead) + (parseFloat(document.getElementById("txtServiceTaxCtrl" + lastno).value)) + (parseFloat(document.getElementById("txtPECessCtrl" + lastno).value)) + (parseFloat(document.getElementById("txtHECessCtrl" + lastno).value)) + (parseFloat(document.getElementById("txtLuxuryCtrl" + lastno).value)) + (parseFloat(document.getElementById("txtVATCtrl" + lastno).value))).toFixed(2);
                        }
                        else {
                            document.getElementById("txtTaxIncGrandTotalCtrl" + lastno).value = parseFloat(totalamounthead).toFixed(2);
                        }
                    }
                    else {
                        document.getElementById("txtServiceTaxCtrl" + lastno).value = '0';
                        document.getElementById("txtPECessCtrl" + lastno).value = '0';
                        document.getElementById("txtHECessCtrl" + lastno).value = '0';
                        document.getElementById("txtTaxIncGrandTotalCtrl" + lastno).value = parseFloat(totalamounthead).toFixed(2);
                    }
                    // Service Tax End


                    ////////// Bottom //////////

                    for (var i = 1; i <= parseFloat(document.getElementById("hidRowCount").value); i++) {
                        //////////// Txable Amount,NonTaxableAmount,TotalAmount //////////
                        var GrossAmt = document.getElementById("txtGrossAmtCtrl" + i).value;
                        var nonTaxableAmt = document.getElementById("txtGrossAmtCtrl" + i).value;
                        var serviceChargeAmt = document.getElementById("txtServiceChargeAmtCtrl" + i).value;
                        var tempTotalAmount = document.getElementById("txtServiceChargeTotalCtrl" + i).value;
                        var ServiceTaxAmt = document.getElementById("txtServiceTaxCtrl" + i).value;
                        var PECessAmt = document.getElementById("txtPECessCtrl" + i).value;
                        var HECessAmt = document.getElementById("txtHECessCtrl" + i).value;
                        var LuxuaryTaxAmt = document.getElementById("txtLuxuryCtrl" + i).value;
                        var VatAmt = document.getElementById("txtVATCtrl" + i).value;
                        var tempTotalGrand = document.getElementById("txtTaxIncGrandTotalCtrl" + i).value;
                        if (GrossAmt == '') {
                            GrossAmt = 0;
                        }
                        if (document.getElementById("hidTaxableNonTaxable" + i).value == 'Taxable') {
                            TotalTaxableAmt += parseFloat(GrossAmt);
                        }
                        else {
                            TotalNonTaxableAmt += parseFloat(GrossAmt);
                        }
                        if (serviceChargeAmt == '') {
                            serviceChargeAmt = 0;
                        }

                        if (tempTotalAmount == '') {
                            tempTotalAmount = 0;
                        }

                        if (ServiceTaxAmt == '') {
                            ServiceTaxAmt = 0;
                        }
                        if (PECessAmt == '') {
                            PECessAmt = 0;
                        }

                        if (HECessAmt == '') {
                            HECessAmt = 0;
                        }

                        if (LuxuaryTaxAmt == '') {
                            LuxuaryTaxAmt = 0;
                        }

                        if (VatAmt == '') {
                            VatAmt = 0;
                        }
                        if (tempTotalGrand == null) {
                            tempTotalGrand = 0;
                        }

                        TotalAmount += parseFloat(tempTotalAmount);
                        TotalServiceTaxAmt += parseFloat(ServiceTaxAmt);
                        TotalServiceChargeAmt += parseFloat(serviceChargeAmt);
                        TotalPECessAmt += parseFloat(PECessAmt);
                        TotalHECessAmt += parseFloat(HECessAmt);
                        TotalLuxuaryTaxAmt += parseFloat(LuxuaryTaxAmt);
                        TotalVatAmt += parseFloat(VatAmt);
                        TotalGrand += parseFloat(tempTotalGrand);


                    }
                    document.getElementById("txtTaxableAmtMain").value = parseFloat(TotalTaxableAmt).toFixed(2);
                    document.getElementById("txtNonTaxableAmtMain").value = parseFloat(TotalNonTaxableAmt).toFixed(2);
                    document.getElementById("txtServiceChargeAmtMain").value = parseFloat(TotalServiceChargeAmt).toFixed(2);
                    document.getElementById("txtTotalAmountMain").value = parseFloat(TotalAmount).toFixed(2);
                    document.getElementById("txtServiceTaxAmtMain").value = parseFloat(TotalServiceTaxAmt).toFixed(2);
                    document.getElementById("txtPECessAmtMain").value = parseFloat(TotalPECessAmt).toFixed(2);
                    document.getElementById("txtHECessAmtMain").value = parseFloat(TotalHECessAmt).toFixed(2);                    
                    document.getElementById("txtLuxuaryTaxMain").value = parseFloat(TotalLuxuaryTaxAmt).toFixed(2);
                    

                    var roundoffamt = 0;
                    var temproundoffamt = 0;

                    temproundoffamt = (parseFloat(TotalAmount) + parseFloat(TotalServiceTaxAmt) + parseFloat(TotalPECessAmt) + parseFloat(TotalHECessAmt) + parseFloat(TotalLuxuaryTaxAmt)).toFixed(2);
                    roundoffamt = (parseFloat(TotalGrand) - parseFloat(temproundoffamt)).toFixed(2);
                    if (parseFloat(TotalAmount) > parseFloat(TotalGrand)) {
                        roundoffamt = 0 - (parseFloat(TotalGrand) - parseFloat(TotalAmount)).toFixed(2);
                    }
                    else {
                        roundoffamt = 0.00;
                    }

                    document.getElementById("txtRoundOffAmtMain").value = parseFloat(roundoffamt).toFixed(2);
                    document.getElementById("txtGrandTotalMain").value = parseFloat(temproundoffamt).toFixed(2);

                }
            }
            else {
                alert('Select Service First!!!');
                document.getElementById("ddlService" + lastno).focus();
            }
        }

        function discountbill(taxablenontaxable, id) {
            var lastno = GetLastNumber(id);
            var disper = Number(document.getElementById("txtDiscountTaxableRate").value);
            var disnonper = Number(document.getElementById("txtNonTaxableDiscountRate").value);
            if (document.getElementById("hidDiscount").value == 'BillLevel') {

                if (taxablenontaxable == 'taxable') {
                    document.getElementById("txtDiscountTaxableAmtMain").value = (parseFloat(document.getElementById("txtTaxableAmtMain").value) * parseFloat(disper) / 100).toFixed(2);
                }
                else {
                    document.getElementById("txtNonTaxableDiscountAmtMain").value = (parseFloat(document.getElementById("txtNonTaxableAmtMain").value) * parseFloat(disnonper) / 100).toFixed(2);
                }

                var originaltaxableamt = 0;
                var originalnontaxableamt = 0;
                for (var i = 1; i <= parseFloat(document.getElementById("hidRowCount").value); i++) {
                    if (document.getElementById("hidTaxableNonTaxable" + i).value == 'Taxable') {
                        if (document.getElementById("ddlService" + i).value != '0') {
                            document.getElementById("txtDiscountRateCtrl" + i).value = parseFloat(disper);
                            document.getElementById("txtDiscountRateCtrl" + i).Blur = "return CalculateGrandTotal('txtDiscountRateCtrl' + " + i + ");";
                            //document.getElementById("txtDiscountRateCtrl" + i).focus();
                            document.getElementById("txtServiceChargeCtrl" + i).focus();
                            document.getElementById("txtGrossAmtCtrl" + i).focus();
                            document.getElementById("txtTaxIncGrandTotalCtrl" + i).focus();
                        }
                    }
                    else {
                        if (document.getElementById("ddlService" + i).value != '0') {
                            document.getElementById("txtDiscountRateCtrl" + i).value = parseFloat(disnonper);
                            document.getElementById("txtDiscountRateCtrl" + i).Blur = "return CalculateGrandTotal('txtDiscountRateCtrl' + " + i + ");";
                            //document.getElementById("txtDiscountRateCtrl" + i).focus();
                            document.getElementById("txtServiceChargeCtrl" + i).focus();
                            document.getElementById("txtGrossAmtCtrl" + i).focus();
                            document.getElementById("txtTaxIncGrandTotalCtrl" + i).focus();
                        }
                    }
                }
            }
        }







        function RoundAmountBottom(id) {
            var lastno = GetLastNumber(id);

            var TotalAmount = 0;
            var tempTotalAmount = 0;
            var TotalEntryAmount = 0;
            var tempTotalEntryAmount = 0;
            var TotalTxableamount = 0;
            var TotalTxableamountHeader = 0;
            for (var i = 1; i <= parseFloat(document.getElementById("hidRowCount").value); i++) {
                tempTotalAmount = document.getElementById("txtServiceChargeTotalCtrl" + i).value;
                if (tempTotalAmount == '') {
                    tempTotalAmount = 0;
                }
                TotalAmount += parseFloat(tempTotalAmount);
                if (document.getElementById("hidGrandTotal").value == 'yes') {
                    tempTotalEntryAmount = document.getElementById("txtTaxIncGrandTotalCtrl" + i).value;
                }
                else {
                    tempTotalEntryAmount = document.getElementById("txtServiceChargeTotalCtrl" + i).value;
                }
                if (tempTotalEntryAmount == '') {
                    tempTotalEntryAmount = 0;
                }
                TotalEntryAmount += parseFloat(tempTotalEntryAmount);

                if (document.getElementById("hidTaxableNonTaxable" + i).value == 'Taxable') {
                    var ServiceTaxRate = parseFloat(document.getElementById("txtServiceTaxRateMain").value).toFixed(2);
                    if (ServiceTaxRate == '') {
                        ServiceTaxRate = 0;
                    }
                    var PECessRate = parseFloat(document.getElementById("txtPECessRateMain").value).toFixed(2);
                    if (PECessRate == '') {
                        PECessRate = 0;
                    }
                    var HECessRate = parseFloat(document.getElementById("txtHECessRateMain").value).toFixed(2);
                    if (HECessRate == '') {
                        HECessRate = 0;
                    }
                    var LuxuaryTaxRate = parseFloat(document.getElementById("txtLuxuaryTaxRateMain").value).toFixed(2);
                    if (LuxuaryTaxRate == '') {
                        LuxuaryTaxRate = 0;
                    }
                    var temptotaltaxableamount = document.getElementById("txtServiceChargeTotalCtrl" + i).value;
                    if (temptotaltaxableamount == '') {
                        temptotaltaxableamount = 0;
                    }
                    TotalTxableamount += parseFloat(temptotaltaxableamount);
                    document.getElementById("txtServiceTaxAmtMain").value = (parseFloat(parseFloat(TotalTxableamount)) * parseFloat(ServiceTaxRate) / 100).toFixed(2);
                    document.getElementById("txtPECessAmtMain").value = (parseFloat(parseFloat(TotalTxableamount)) * parseFloat(PECessRate / 10) / 100).toFixed(2);
                    document.getElementById("txtHECessAmtMain").value = (parseFloat(parseFloat(TotalTxableamount)) * parseFloat(HECessRate / 10) / 100).toFixed(2);
                    document.getElementById("txtLuxuaryTaxMain").value = '0';
                }

            }


            if (document.getElementById("hidSaleLevel").value == "ItemLevel") {
                var temptotaltaxableamountheader = document.getElementById("txtServiceChargeTotalCtrl" + lastno).value;
                if (temptotaltaxableamountheader == '') {
                    temptotaltaxableamountheader = 0;
                }
                TotalTxableamountHeader = parseFloat(temptotaltaxableamountheader);
                document.getElementById("txtServiceTaxCtrl" + lastno).value = (parseFloat(parseFloat(TotalTxableamountHeader)) * parseFloat(ServiceTaxRate) / 100).toFixed(2);    // Service Tax
                document.getElementById("txtPECessCtrl" + lastno).value = (parseFloat(parseFloat(TotalTxableamountHeader)) * parseFloat(PECessRate / 10) / 100).toFixed(2);   // P.E Cess
                document.getElementById("txtHECessCtrl" + lastno).value = (parseFloat(parseFloat(TotalTxableamountHeader)) * parseFloat(HECessRate / 10) / 100).toFixed(2);  // H.E Cess
            }

            var servicetaxamount = document.getElementById("txtServiceTaxAmtMain").value;
            if (servicetaxamount == '') {
                servicetaxamount = 0;
            }
            var TaxPeCessamount = document.getElementById("txtPECessAmtMain").value;
            if (TaxPeCessamount == '') {
                TaxPeCessamount = 0;
            }
            var TaxHeCessamount = document.getElementById("txtHECessAmtMain").value;
            if (TaxHeCessamount == '') {
                TaxHeCessamount = 0;
            }
            var TaxLuxuaryTax = document.getElementById("txtLuxuaryTaxMain").value;
            if (TaxLuxuaryTax == '') {
                TaxLuxuaryTax = 0;
            }

            var roundoffamt = 0;
            var temproundoffamt = 0;

            temproundoffamt = (parseFloat(TotalAmount) + parseFloat(servicetaxamount) + parseFloat(TaxPeCessamount) + parseFloat(TaxHeCessamount) + parseFloat(TaxLuxuaryTax)).toFixed(2);
            roundoffamt = (parseFloat(TotalEntryAmount) - parseFloat(temproundoffamt)).toFixed(2);
            if (parseFloat(TotalAmount) > parseFloat(TotalEntryAmount)) {
                roundoffamt = 0 - (parseFloat(TotalAmount) - parseFloat(TotalEntryAmount)).toFixed(2);
            }
            //alert(TotalAmount);
            document.getElementById("txtRoundOffAmtMain").value = roundoffamt;
            document.getElementById("txtGrandTotalMain").value = TotalEntryAmount.toFixed(2);
        }


        function PostBilling(id) {
            if (id == 'chkapplysurcurr') {
                if (document.getElementById(id).checked) {
                    document.getElementById("txteffectiveratecurr").value = parseFloat(document.getElementById("hideffectiverate").value);
                }
                else {
                    document.getElementById("txteffectiveratecurr").value = (parseFloat(document.getElementById("hideffectiverate").value) - parseFloat(document.getElementById("hidsurchargerate").value));
                }
            }
            else {
                if (document.getElementById(id).checked) {
                    document.getElementById("txteffectiveratepre").value = parseFloat(document.getElementById("hideffectiverate").value);
                }
                else {
                    document.getElementById("txteffectiveratepre").value = (parseFloat(document.getElementById("hideffectiverate").value) - parseFloat(document.getElementById("hidsurchargerate").value));
                }
            }

        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="divmain" style="width: 96%; margin-left: 1%;">
        <acc:heading ID="pagehead" runat="server" HeadingText="Sale Invoice" />
        <div style="margin-left: 5%; margin-right: 3%; width: 85%" align="center">
            <asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label>
        </div>
        <asp:HiddenField ID="hidTranType" runat="server" />
        <asp:HiddenField ID="hidSaleLevel" runat="server" />
        <%-- Item Level Or Bill Level --%>
        <asp:HiddenField ID="hidGrandTotal" runat="server" />
        <%-- TaxInclusive --%>
        <asp:HiddenField ID="hidSercharge" runat="server" />
        <%-- Show Service Charge --%>
        <asp:HiddenField ID="hidTaxType" runat="server" />
        <%-- ServiceTax ServiceTax,LuxuaryTax ServiceTax,VAT --%>
        <asp:HiddenField ID="hidDiscount" runat="server" />
        <%-- Apply Discount None,BillLevel,ItemLevel --%>
        <asp:HiddenField ID="hidUnit" runat="server" />
        <%-- Addition Unit Height,Widht,Radious --%>
        <asp:HiddenField ID="hidUnitRate" runat="server" />
        <%-- Unit and Rate --%>
    </div>
    <div style="width: 96%; margin-left: 1%; margin-top: 10px;">
        <table style="width: 100%;" class="tablecontent">
            <tr>
                <td>
                    <b>Bill Format <span style="color: Red">* </span></b>
                </td>
                <td>
                    <asp:DropDownList ID="ddlFormat" runat="server" CssClass="dropdown" AutoPostBack="true"
                        OnSelectedIndexChanged="ddlFormat_SelectedIndex">
                    </asp:DropDownList>
                </td>
                <td>
                    <b>Customer <span style="color: Red;">* </span></b>
                </td>
                <td>
                    <asp:DropDownList ID="ddlCustomer" runat="server" CssClass="dropdown" AutoPostBack="true"
                        OnSelectedIndexChanged="ddlCustomer_SelectedIndex" Width="200px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Bill No. <span style="color: Red;">* </span></b>
                </td>
                <td>
                    <asp:TextBox ID="txtPrefix" runat="server" Width="60px" CssClass="input" onKeyPress="return false"
                        onKeydown="EnabledTabKey(this.id, event);"></asp:TextBox>
                    <AjaxControl:TextBoxWatermarkExtender ID="prefixWater" runat="server" TargetControlID="txtPrefix"
                        WatermarkText="Prefix" WatermarkCssClass="watermark_textbox">
                    </AjaxControl:TextBoxWatermarkExtender>
                    <asp:TextBox ID="txtBillNo" runat="server" Width="60px" CssClass="inputnumber" ValidationGroup="V"
                        MaxLength="10"></asp:TextBox>
                    <AjaxControl:TextBoxWatermarkExtender ID="voucherWater" runat="server" TargetControlID="txtBillNo"
                        WatermarkText="Number" WatermarkCssClass="watermark_textbox">
                    </AjaxControl:TextBoxWatermarkExtender>
                    <asp:TextBox ID="txtSuffix" runat="server" Width="60px" CssClass="input" onKeyPress="return false"
                        onKeydown="EnabledTabKey(this.id, event);"></asp:TextBox>
                    <AjaxControl:TextBoxWatermarkExtender ID="suffixWater" runat="server" TargetControlID="txtSuffix"
                        WatermarkText="Suffix" WatermarkCssClass="watermark_textbox">
                    </AjaxControl:TextBoxWatermarkExtender>
                </td>
                <td>
                    <b>Address</b>
                </td>
                <td colspan="5">
                    <asp:TextBox ID="txtAddress" runat="server" CssClass="input" Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Date <span style="color: Red;">* </span></b>
                </td>
                <td>
                    <asp:TextBox ID="txtDate" runat="server" CssClass="input" OnTextChanged="txtDate_TextChanged"
                        AutoPostBack="true"></asp:TextBox>
                    <asp:ImageButton ID="btnDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                    <AjaxControl:CalendarExtender ID="calrec" runat="server" PopupButtonID="btnDate"
                        TargetControlID="txtDate" Format="dd/MM/yyyy">
                    </AjaxControl:CalendarExtender>
                    <AjaxControl:MaskedEditExtender ID="maskExtrec" runat="server" MaskType="Date" Mask="99/99/9999"
                        TargetControlID="txtDate" CultureName="en-GB">
                    </AjaxControl:MaskedEditExtender>
                    <AjaxControl:MaskedEditValidator ID="maskValidrec" runat="server" ControlExtender="maskExtrec"
                        InvalidValueMessage="Invalid Date" IsValidEmpty="true" Display="Dynamic" ValidationGroup="V"
                        ControlToValidate="txtDate"></AjaxControl:MaskedEditValidator>
                </td>
                <td>
                    <b>Ref no <span style="color: Red">*</span></b>
                </td>
                <td>
                    <asp:TextBox ID="txtRefNo" runat="server" CssClass="inputnumber" MaxLength="48" Style="width: 70px;"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Other Ref</b>
                </td>
                <td>
                    <asp:TextBox ID="txtOtherRef" runat="server" CssClass="input" MaxLength="48" Style="width: 70px;"></asp:TextBox>
                </td>
                <td>
                    <b>Credit Days</b>
                </td>
                <td>
                    <asp:TextBox ID="txtCreditDays" runat="server" CssClass="input" MaxLength="3" Style="width: 70px;
                        text-align: right;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    <asp:HiddenField ID="hidCustomerprefid" runat="server" />
                </td>
            </tr>
        </table>
        <div style="overflow: scroll; width: 100%; margin-top: 10px;" class="tablecontent">
            <asp:HiddenField ID="hidRowCount" runat="server" Value="2" />
            <table id="tblMainInvoice" runat="server" width="100%" style="margin-bottom: 10px;">
                <tr>
                    <td style="border-right: 1px solid #818181;" class="headtd" align="center" id="tdService"
                        runat="server">
                        Nature of Service
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdDescription" runat="server">
                        Description
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdYearRef" runat="server">
                        Year Ref.
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdUom" runat="server">
                        Unit of Mesurement
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdUnit2" runat="server">
                        Unit 2
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdUnit3" runat="server">
                        Unit 3
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdUnit4" runat="server">
                        Unit 4
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdUnitRate" runat="server">
                        Unit
                    </td>
                    <td style="border-right: 1px solid #818181;" class="headtd" align="center" id="tdRate"
                        runat="server">
                        Rate
                    </td>
                    <td style="border-right: 1px solid #818181;" class="headtd" align="center" id="tdGrossAmt"
                        runat="server">
                        Gross Amount
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdDiscountRate" runat="server">
                        Discount(%)
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdDiscountAmt" runat="server">
                        Discount Amount
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdServiceCharge" runat="server">
                        Service Charge(%)
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdServiceChargeAmt" runat="server">
                        Service Charge
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdServiceChargeTotal" runat="server">
                        Total Amount
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdServiceTax" runat="server">
                        Service Tax
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdPECess" runat="server">
                        P.E Cess
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdHECess" runat="server">
                        H.E Cess
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdLuxury" runat="server">
                        Luxury
                    </td>
                    <td style="display: none; border-right: 1px solid #818181;" class="headtd" align="center"
                        id="tdVAT" runat="server">
                        VAT
                    </td>
                    <td style="display: none;" class="headtd" align="center" id="tdTaxIncGrandTotal"
                        runat="server">
                        Grand Total
                    </td>
                </tr>
                <tr>
                    <td id="tdServiceCtrl1" runat="server" align="center">
                        <asp:DropDownList ID="ddlService1" runat="server" AutoPostBack="true" CssClass="dropdown"
                            Width="150px" OnSelectedIndexChanged="ddlService_SelectedIndexChanged" onchange="return ValidateRequired(this.id);">
                        </asp:DropDownList>
                        <asp:HiddenField ID="hidTaxableNonTaxable1" runat="server" />
                        <asp:HiddenField ID="hidServiceIncomeLid1" runat="server" />
                    </td>
                    <td style="display: none;" id="tdDescriptionCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtDescriptionCtrl1" runat="server" MaxLength="248" CssClass="input"
                            Style="display: none;"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdYearRefCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtYearRefCtrl1" runat="server" CssClass="input" MaxLength="48"
                            Style="width: 70px; display: none;"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUomCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtUomCtrl1" runat="server" CssClass="input" MaxLength="25" Style="display: none;"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnit2Ctrl1" runat="server" align="center">
                        <asp:TextBox ID="txtUnit2Ctrl1" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnit3Ctrl1" runat="server" align="center">
                        <asp:TextBox ID="txtUnit3Ctrl1" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnit4Ctrl1" runat="server" align="center">
                        <asp:TextBox ID="txtUnit4Ctrl1" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnitRateCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtUnitRateCtrl1" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"
                            onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                    <td id="tdRateCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtRateCtrl1" runat="server" CssClass="inputnumber" Style="width: 70px;"
                            MaxLength="10" onBlur="return CalculateGrandTotal(this.id);" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td id="tdGrossAmtCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtGrossAmtCtrl1" runat="server" CssClass="inputnumber" Style="width: 120px;"
                            OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                        <asp:HiddenField ID="hidServiceCharge1" runat="server" />
                    </td>
                    <td style="display: none;" id="tdDiscountRateCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtDiscountRateCtrl1" runat="server" Style="width: 80px; display: none;"
                            CssClass="inputnumber" OnKeyPress="return isNumberKey(this.id,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdDiscountAmtCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtDiscountAmtCtrl1" runat="server" Style="width: 120px; display: none;"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceChargeCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtServiceChargeCtrl1" Style="width: 120px; display: none;" MaxLength="5"
                            runat="server" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.id,event);"
                            onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceChargeAmtCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtServiceChargeAmtCtrl1" Style="width: 100px; display: none;" MaxLength="5"
                            runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceChargeTotalCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtServiceChargeTotalCtrl1" Style="width: 100px; display: none;"
                            MaxLength="5" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceTaxCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtServiceTaxCtrl1" Style="width: 100px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdPECessCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtPECessCtrl1" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdHECessCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtHECessCtrl1" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdLuxuryCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtLuxuryCtrl1" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdVATCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtVATCtrl1" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdTaxIncGrandTotalCtrl1" runat="server" align="center">
                        <asp:TextBox ID="txtTaxIncGrandTotalCtrl1" runat="server" Style="width: 120px; display: none;"
                            CssClass="DisableInputNumber" OnKeyPress="return isNumberKey(this.id,event);"
                            onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td id="tdServiceCtrl2" runat="server" align="center">
                        <asp:DropDownList ID="ddlService2" runat="server" AutoPostBack="true" CssClass="dropdown"
                            Width="150px" OnSelectedIndexChanged="ddlService_SelectedIndexChanged" onchange="return ValidateRequired(this.id);">
                        </asp:DropDownList>
                        <asp:HiddenField ID="hidTaxableNonTaxable2" runat="server" />
                        <asp:HiddenField ID="hidServiceIncomeLid2" runat="server" />
                    </td>
                    <td style="display: none;" id="tdDescriptionCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtDescriptionCtrl2" runat="server" MaxLength="248" CssClass="input"
                            Style="display: none;"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdYearRefCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtYearRefCtrl2" runat="server" CssClass="input" MaxLength="48"
                            Style="width: 70px; display: none;"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUomCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtUomCtrl2" runat="server" CssClass="input" MaxLength="25" Style="display: none;"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnit2Ctrl2" runat="server" align="center">
                        <asp:TextBox ID="txtUnit2Ctrl2" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnit3Ctrl2" runat="server" align="center">
                        <asp:TextBox ID="txtUnit3Ctrl2" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnit4Ctrl2" runat="server" align="center">
                        <asp:TextBox ID="txtUnit4Ctrl2" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdUnitRateCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtUnitRateCtrl2" runat="server" CssClass="inputnumber" MaxLength="10"
                            Style="width: 70px; display: none;" OnKeyPress="return isNumberKey(this.id,event);"
                            onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                    <td id="tdRateCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtRateCtrl2" runat="server" CssClass="inputnumber" Style="width: 70px;"
                            MaxLength="10" onBlur="return CalculateGrandTotal(this.id);" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                    </td>
                    <td id="tdGrossAmtCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtGrossAmtCtrl2" runat="server" CssClass="inputnumber" Style="width: 120px;"
                            OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                        <asp:HiddenField ID="hidServiceCharge2" runat="server" />
                    </td>
                    <td style="display: none;" id="tdDiscountRateCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtDiscountRateCtrl2" runat="server" Style="width: 80px; display: none;"
                            CssClass="inputnumber" OnKeyPress="return isNumberKey(this.id,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdDiscountAmtCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtDiscountAmtCtrl2" runat="server" Style="width: 120px; display: none;"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceChargeCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtServiceChargeCtrl2" Style="width: 120px; display: none;" MaxLength="5"
                            runat="server" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.id,event);"
                            onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceChargeAmtCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtServiceChargeAmtCtrl2" Style="width: 100px; display: none;" MaxLength="5"
                            runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceChargeTotalCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtServiceChargeTotalCtrl2" Style="width: 100px; display: none;"
                            MaxLength="5" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdServiceTaxCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtServiceTaxCtrl2" Style="width: 100px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdPECessCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtPECessCtrl2" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdHECessCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtHECessCtrl2" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdLuxuryCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtLuxuryCtrl2" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdVATCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtVATCtrl2" Style="width: 70px; display: none;" runat="server"
                            CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    </td>
                    <td style="display: none;" id="tdTaxIncGrandTotalCtrl2" runat="server" align="center">
                        <asp:TextBox ID="txtTaxIncGrandTotalCtrl2" runat="server" Style="width: 120px; display: none;"
                            CssClass="DisableInputNumber" OnKeyPress="return isNumberKey(this.id,event);"
                            onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <table style="width: 90%; margin-top: 10px; margin-bottom: 10px; margin-left: 15px;"
                align="left">
                <tr>
                    <td>
                        <asp:LinkButton ID="btnAddMore" runat="server" OnClick="AddMore_Click"> 
                            <img src="../../Images/More.jpg" alt="Add New Row" />
                        </asp:LinkButton>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <table style="width: 96%; margin-left: 1%; margin-top: 10px;" class="tablecontent">
        <tr>
            <td style="width: 60%;" valign="top">
                <table style="width: 100%; margin-top: 4px;" class="tablecontent">
                    <tr>
                        <td>
                            <table style="width: 100%;" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td class="headtd" style="width: 100%;" colspan="3">
                                        <b>Post Billing</b>
                                        <asp:HiddenField ID="hidamtcess" runat="server" />
                                        <asp:HiddenField ID="hidtdsrate" runat="server" />
                                        <asp:HiddenField ID="hidcess1rate" runat="server" />
                                        <asp:HiddenField ID="hidcess2rate" runat="server" />
                                        <asp:HiddenField ID="hidsurchargerate" runat="server" />
                                        <asp:HiddenField ID="hideffectiverate" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="headtd" style="width: 100%;" colspan="3">
                                        <b>Current Bill</b>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="3">
                                        <asp:CheckBox ID="chkapplysurcurr" runat="server" Text="ApplySurcharge" Checked="true"
                                            onclick="return PostBilling(this.id);" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>Effective Rate</b>
                                    </td>
                                    <td>
                                        <b>Net TDS</b>
                                    </td>
                                    <td>
                                        <b>Net Amt Receivable </b>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:TextBox ID="txteffectiveratecurr" runat="server" CssClass="DisableInputNumber"
                                            Enabled="false" Style="width: 120px;"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtnettdscurr" runat="server" CssClass="DisableInputNumber" Enabled="false"
                                            Style="width: 120px;"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtnetamtreceiablecurr" runat="server" CssClass="DisableInputNumber"
                                            Enabled="false" Style="width: 120px;"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="headtd" style="width: 100%;" colspan="3">
                                        <b>Previous Bill</b>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="3">
                                        <asp:CheckBox ID="chkappsurpre" runat="server" Text="ApplySurcharge" Checked="true"
                                            onclick="return PostBilling(this.id);" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>Effective Rate</b>
                                    </td>
                                    <td>
                                        <b>Net TDS</b>
                                    </td>
                                    <td colspan="2">
                                        <b>Net Amt Receivable </b>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:TextBox ID="txteffectiveratepre" runat="server" CssClass="DisableInputNumber"
                                            Enabled="false" Style="width: 120px;"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtnettdspre" runat="server" CssClass="DisableInputNumber" Enabled="false"
                                            Style="width: 120px;"></asp:TextBox>
                                    </td>
                                    <td colspan="2">
                                        <asp:TextBox ID="txtnetamtreceiablepre" runat="server" CssClass="DisableInputNumber"
                                            Enabled="false" Style="width: 120px;"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                            <table style="width: 100%; margin-top: 10px;">
                                <tr>
                                    <td id="tdnarration" runat="server">
                                        <b>Narration</b>
                                    </td>
                                    <td id="tdnarrationtext" runat="server">
                                        <asp:TextBox ID="txtnarration" runat="server" MaxLength="248" CssClass="input" Style="width: 130px;"></asp:TextBox>
                                    </td>
                                    <td id="tdservicedby" runat="server">
                                        <b>Serviced By</b>
                                    </td>
                                    <td id="tdservicedbytext" runat="server">
                                        <asp:TextBox ID="txtservicedby" MaxLength="50" runat="server" CssClass="input" Style="width: 130px;"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td id="tdpreparedby" runat="server">
                                        <b>Prepared By</b>
                                    </td>
                                    <td id="tdpreparedbytext">
                                        <asp:TextBox ID="txtpreparedby" runat="server" MaxLength="50" CssClass="input" Style="width: 130px;"></asp:TextBox>
                                    </td>
                                    <td id="tdcheckedby" runat="server">
                                        <b>Checked By</b>
                                    </td>
                                    <td id="tdcheckedbytext">
                                        <asp:TextBox ID="txtcheckedby" runat="server" MaxLength="50" CssClass="input" Style="width: 130px;"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td id="tdremarks" runat="server">
                                        <b>Remarks</b>
                                    </td>
                                    <td id="tdremarkstext" colspan="3" style="width: 80%;">
                                        <asp:TextBox ID="txtremarks" runat="server" MaxLength="50" Style="width: 80%;" CssClass="input"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 40%;" valign="top">
                <table id="tblcalculation" runat="server" style="width: 99%; margin-top: 4px;" class="tablecontent">
                    <tr>
                        <td class="headtd" colspan="3">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td id="tdtaxableamt" runat="server" colspan="2">
                            <b>Taxable Amount</b>
                        </td>
                        <td id="tdtaxableamttext" runat="server" align="right" style="width: 110px;">
                            <asp:TextBox ID="txtTaxableAmtMain" runat="server" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);" Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tddiscounttax" runat="server" style="display: none;">
                            <b>Discount</b>
                        </td>
                        <td id="tddiscounttaxper" runat="server" align="right" style="width: 80px; display: none;">
                            <asp:TextBox ID="txtDiscountTaxableRate" runat="server" Width="70px" onblur="discountbill('taxable',this.id);"
                                CssClass="inputnumber" Style="display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                        </td>
                        <td id="tddiscounttaxamt" runat="server" align="right" style="width: 110px; display: none;">
                            <asp:TextBox ID="txtDiscountTaxableAmtMain" runat="server" CssClass="DisableInputNumber"
                                Style="width: 100px; display: none;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr id="trNonTaxable" runat="server">
                        <td colspan="2">
                            <b>Non-Taxable Amount</b>
                        </td>
                        <td align="right" style="width: 110px;">
                            <asp:TextBox ID="txtNonTaxableAmtMain" runat="server" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);" Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tddiscountnontax" runat="server" style="display: none;">
                            <b>Discount</b>
                        </td>
                        <td id="tdnondiscountper" runat="server" align="right" style="width: 80px; display: none;">
                            <asp:TextBox ID="txtNonTaxableDiscountRate" runat="server" Width="70px" onblur="discountbill('nontaxable',this.id);"
                                CssClass="inputnumber" Style="display: none;" OnKeyPress="return isNumberKey(this.id,event);"></asp:TextBox>
                        </td>
                        <td id="tdnondiscounttaxamt" runat="server" colspan="2" align="right" style="width: 110px;
                            display: none;">
                            <asp:TextBox ID="txtNonTaxableDiscountAmtMain" runat="server" CssClass="DisableInputNumber"
                                Style="width: 100px; display: none;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr id="trServiceCharges" runat="server">
                        <td style="display: none;" colspan="2">
                            <b>Service Charge Amount</b>
                        </td>
                        <td align="right" style="width: 110px;">
                            <asp:TextBox ID="txtServiceChargeAmtMain" runat="server" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);" Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tdtotalamount" runat="server" colspan="2">
                            <b>Total Amount</b>
                        </td>
                        <td id="tdtotalamounttext" runat="server" align="right" style="width: 110px;">
                            <asp:TextBox ID="txtTotalAmountMain" runat="server" align="right" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);" Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tdServiceTaxMain" runat="server">
                            <b>Service Tax %</b>
                        </td>
                        <td id="tdservicetaxtext" runat="server" align="right" style="width: 80px;">
                            <asp:TextBox ID="txtServiceTaxRateMain" runat="server" Width="70px" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox><asp:HiddenField
                                    ID="hidServiceTaxLid" runat="server" />
                        </td>
                        <td align="right" style="width: 110px;">
                            <asp:TextBox ID="txtServiceTaxAmtMain" runat="server" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);" Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tdPECessMain" runat="server">
                            <b>P.E Cess %</b>
                        </td>
                        <td id="tdpecesstext" runat="server" align="right" style="width: 80px;">
                            <asp:TextBox ID="txtPECessRateMain" runat="server" Width="70px" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox><asp:HiddenField
                                    ID="hidPECessLid" runat="server" />
                        </td>
                        <td align="right" style="width: 110px;">
                            <asp:TextBox ID="txtPECessAmtMain" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"
                                Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tdHECessMain" runat="server">
                            <b>H.E Cess %</b>
                        </td>
                        <td id="tdhecesstext" runat="server" align="right" style="width: 80px;">
                            <asp:TextBox ID="txtHECessRateMain" runat="server" Width="70px" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox><asp:HiddenField
                                    ID="hidHECessLid" runat="server" />
                        </td>
                        <td align="right" style="width: 110px;">
                            <asp:TextBox ID="txtHECessAmtMain" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"
                                Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tdluxuarytax" runat="server">
                            <b>Luxuary Tax %</b>
                        </td>
                        <td id="tdluxuarytaxtext" runat="server" align="right" style="width: 80px;">
                            <asp:TextBox ID="txtLuxuaryTaxRateMain" runat="server" Width="70px" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                            <asp:HiddenField ID="hidluxuarytaxpercent" runat="server" />
                        </td>
                        <td align="right" style="width: 110px;">
                            <asp:TextBox ID="txtLuxuaryTaxMain" runat="server" CssClass="DisableInputNumber"
                                Style="width: 100px;" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                        </td>
                    </tr>
                    <tr id="trVatMain" runat="server">
                        <td>
                            VAT
                        </td>
                        <td>
                            <asp:TextBox ID="txtVATMain" runat="server" Width="70px" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tdroundofamt" runat="server">
                            <b>Round Off Amount</b>
                        </td>
                        <td id="tdroundofamttext" runat="server" colspan="2" align="right">
                            <asp:TextBox ID="txtRoundOffAmtMain" runat="server" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);" Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td id="tdgrandtotal" runat="server">
                            <b>Grand Total</b>
                        </td>
                        <td id="tdGrandTotalMain" runat="server" colspan="2" align="right">
                            <asp:TextBox ID="txtGrandTotalMain" runat="server" CssClass="DisableInputNumber"
                                onKeyDown="return EnabledTabKey(this.id, event);" Style="width: 100px;"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <table style="width: 96%;">
        <tr>
            <td align="center">
                <asp:Button ID="btnSave" Text="Save" runat="server" CssClass="button" OnClick="btnSave_Click" />
                &nbsp;
                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CssClass="button" OnClick="btnCancel_Click" />
            </td>
        </tr>
    </table>
    <asp:GridView ID="grid" runat="server">
    </asp:GridView>
    <br />
    <%--  <asp:GridView ID="GridDisplaysale" runat="server" Width="100%" CssClass="gridview" AlternatingRowStyle-CssClass="gridview_alternate">
      
    </asp:GridView>--%>
    </form>
</body>
</html>
